Skip to content

Implementing result pipe drainage on cancellation#25981

Open
Copilot wants to merge 9 commits into
mainfrom
copilot/drain-result-pipe-on-cancel
Open

Implementing result pipe drainage on cancellation#25981
Copilot wants to merge 9 commits into
mainfrom
copilot/drain-result-pipe-on-cancel

Conversation

Copy link
Copy Markdown

Copilot AI commented May 29, 2026

Pull request created by AI Agent

eleanorjboyd and others added 2 commits June 1, 2026 09:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The pure event-driven drain in this PR can hang the adapter's finally
block forever if reader.onClose never fires - which happens in CI on
the segfault/coverage/large-workspace execution tests (abnormal
subprocess exit, platform-specific named-pipe quirks).

Add awaitDeferredWithTimeout helper and use it in both unittest and
pytest execution adapters' finally blocks. By the time we hit finally,
runTestsNew has already awaited the subprocess 'exit' event, so a few
seconds is plenty for any buffered pipe data to flush. The timeout
acts purely as a backstop - the normal path still resolves promptly
via reader.onClose.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the test execution adapters’ result-pipe lifecycle so cancellation no longer detaches the result listener prematurely, allowing buffered results to drain and preventing hangs by adding a timeout backstop.

Changes:

  • Stop resolving the “server closed” deferred on cancellation so the result pipe can drain naturally via reader.onClose.
  • Add awaitDeferredWithTimeout() + RESULT_PIPE_DRAIN_TIMEOUT_MS and use it in pytest/unittest adapters to avoid indefinite waits.
  • Add unit tests covering drain-on-cancel behavior for startRunResultNamedPipe and timeout behavior.
Show a summary per file
File Description
src/client/testing/testController/common/utils.ts Adds drain timeout constant + awaitDeferredWithTimeout, and adjusts result-pipe disposal behavior to be close-driven.
src/client/testing/testController/unittest/testExecutionAdapter.ts Stops resolving the “server closed” deferred on cancellation and uses timeout-backed waiting in finally.
src/client/testing/testController/pytest/pytestExecutionAdapter.ts Uses timeout-backed waiting for result-pipe closure in finally.
src/test/testing/testController/utils.unit.test.ts Adds unit tests validating drain-on-cancel semantics and timeout behavior.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment thread src/client/testing/testController/common/utils.ts
Comment thread src/client/testing/testController/unittest/testExecutionAdapter.ts Outdated
Comment thread src/test/testing/testController/utils.unit.test.ts
- Use traceInfo instead of console.log in unittest cancellation handler
  (consistent with other test controller adapters; routes through the
  extension output channel).
- Clarify awaitDeferredWithTimeout log message: the underlying deferred
  is not actually resolved on timeout, the helper just stops waiting.
- Fill in required ExecutionTestPayload fields (status, error) in the
  test helper so emitted messages match the real runner schema.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd eleanorjboyd marked this pull request as ready for review June 8, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required skip-issue-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants